#include "match.h"
#include <iostream>
using namespace std;


int main(int argc, char* argv[])
{

	IImage* pImage1 = NULL;
	IImage* pImage2 = NULL;
	CoInitialize(NULL);
	::CoCreateInstance(CLSID_ImageDriver, NULL, CLSCTX_ALL, IID_IImage, (void**)&pImage1);
	::CoCreateInstance(CLSID_ImageDriver, NULL, CLSCTX_ALL, IID_IImage, (void**)&pImage2);

	int xsize1, xsize2, ysize1, ysize2, nband1, nband2;
	pImage1->Open(_bstr_t("D:\\1.tif"), modeRead);
	pImage1->GetBandNum(&nband1);
	pImage1->GetCols(&xsize1);
	pImage1->GetRows(&ysize1);
	uchar* pbuf1 = new uchar[xsize1*ysize1*nband1];
	pImage1->ReadImg(0, 0, xsize1, ysize1, pbuf1, xsize1, ysize1, nband1, 0, 0, xsize1, ysize1, -1, 0);
	pImage1->Close();
	
	pImage2->Open(_bstr_t("D:\\2.tif"), modeRead);
	pImage2->GetBandNum(&nband2);
	pImage2->GetCols(&xsize2);
	pImage2->GetRows(&ysize2);
	uchar* pbuf2 = new uchar[xsize2*ysize2*nband2];
	pImage2->ReadImg(0, 0, xsize2, ysize2, pbuf2, xsize2, ysize2, nband2, 0, 0, xsize2, ysize2, -1, 0);
	pImage2->Close();
	match m(pbuf1, nband1, xsize1, ysize1, pbuf2, nband2, xsize2, ysize2);
	std::vector<SamePoint> result;
	m.domatchfrombuf(result);
	/*match m("D:\\1.tif", "D:\\2.tif");
	std::vector<SamePoint> result;
	m.domatch(result);*/
	system("pause");
	return 0;
}
